from PyQt5.QtWidgets import QApplication, QMessageBox
from PyQt5 import uic




class Uni:
    def __init__(self):
        # 从文件中加载UI定义

        # 从 UI 定义中动态 创建一个相应的窗口对象
        # 注意：里面的控件对象也成为窗口对象的属性了
        # 比如 self.ui.button , self.ui.textEdit
        self.ui = uic.loadUi('test-untitled.ui')

        self.ui.tab_1.pushButton.clicked.connect(self.handlecalc2)
        self.ui.buttonGroup.buttonClicked.connect(self.ty)
        self.ui.buttonGroup_2.buttonClicked.connect(self.dim)
        self.ui.tab_2.pushButton_2.clicked.connect(self.handlecalc2)
        self.ui.tab_3.pushButton_3.clicked.connect(self.handlecalc2)

    def dragenterevent(self, event):# 检查拖入的内容是否包含文件路径
            if event.mimeData().hasUrls():# 如果是文件路径，接受拖放操作
                event.acceptProposedAction()

    def dropevent(self, event):# 获取拖入的文件路径
            for url in event.mimeData().urls():
                file_path = url.toLocalFile()

    def ty(self):
        but1 =self.ui.buttonGroup.checkedButton()
        but1.text()#存储所选的图像类型的按钮文本

    def dim(self):
        but2 =self.ui.buttonGroup_2.checkedButton()
        but2.text()#存储所选的图像维度的按钮文本

    def handlecalc1(self):
        fml=self.ui.tab_1.plainTextEdit.toPlaniText() #fml存储函数式
        lefnum=self.ui.tab_1.doubleSpinBox.value()
        rignum=self.ui.tab_1.doubleSpinBox_2.value()


    def handlecalc2(self):
        exda = self.ui.tab_2.plainTextEdit.toPlainText()   #exda保存的处理数据
        method = self.ui.comboBox.currentText()     #method保存处理方法

    def handlecalc3(self):
        mat=self.ui.tab_3.plainTextEdit.toPlaniText() #存储邻接矩阵




app = QApplication([])
stats = Uni()
stats.ui.show()
app.exec_()